<?php

// $Id: login_form.class.php 1571 2009-01-13 13:08:33Z ogrebg $

require_once(TANGRA_MAIN_DIR.'form/form.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/text/form_field_text.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/password/form_field_password.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/checkbox/form_field_checkbox.class.php');
require_once(TANGRA_MAIN_DIR.'form/fields/hidden/form_field_hidden.class.php');

require_once(TANGRA_MAIN_DIR.'/form/static_html_form_generator.class.php');



class Admin_Login_Form extends Form {
	function __construct() {
		parent::__construct('login_form', 'admin/login.php');

		$this->add_field(new Form_Field_Text('username', true, 50));

		$f_password = new Form_Field_Password('password', true, 50);
		$f_password->add_potential_error('invalid_login');
		$f_password->add_potential_error('account_not_active');
		$this->add_field($f_password);

		$f_remember = new Form_Field_Checkbox('remember', false);
		$this->add_field($f_remember);

		$f_return_to = new Form_Field_Hidden('return_to');
		$this->add_field($f_return_to);

		$f_return_to_params = new Form_Field_Hidden('return_to_params');
		$this->add_field($f_return_to_params);
	}



	public function generate_html() {
		$html_gen = new Static_HTML_Form_Generator($this, 'modules/form_html_tpl_static_ajax_metallic_en', 'en');
		$html_gen->create_default_tpl_maps();
		$html_gen->change_field_p_error_map_entry('password', 'invalid_login', 'forms/en/login/field_error_invalid_login.tpl');
		$html_gen->change_field_p_error_map_entry('password', 'account_not_active', 'forms/en/login/field_error_account_not_active.tpl');
		printbr(htmlentities($html_gen->get_static_html()));
	}
}


